package com.von.nhcf.controller;

import com.von.nhcf.api.MysqlRemoteService;
import com.von.nhcf.constant.NhcfConstant;
import com.von.nhcf.entity.vo.PortalTypeVO;
import com.von.nhcf.util.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * 显示首页
 * @author von
 */
@Controller
public class PortalController {
    @Autowired
    MysqlRemoteService mysqlRemoteService;

    @RequestMapping("/")
    public String showPortal(ModelMap modelMap) {
        ResultEntity<List<PortalTypeVO>> projectTypeVORemote = mysqlRemoteService.getProjectTypeVORemote();
        if (ResultEntity.getSUCCESS().equals(projectTypeVORemote.getResult())) {
            List<PortalTypeVO> data = projectTypeVORemote.getData();
            modelMap.addAttribute(NhcfConstant.ATTR_NAME_PORTAL_DATA, data);
        }

        return "portal";
    }

}
